package com.reggie.module.entity.po;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.reggie.module.entity.vo.dishVo.DishVo;
import com.reggie.module.mapper.CategoryMapper;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.beans.Transient;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

import static com.reggie.common.Constant.LOGIN_SESSION;

/**
 * 菜品
 */
@Data
public class Dish implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long id;


    //菜品名称
    private String name;


    //菜品分类id
    private Long categoryId;

    //菜品分类名
    @TableField(exist = false)
    private String categoryName;


    //菜品价格
    private BigDecimal price;


    //商品码
    private String code;


    //图片
    private String image;


    //描述信息
    private String description;


    //0 停售 1 起售
    private Integer status;


    //顺序
    private Integer sort;


    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;


    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;


    @TableField(fill = FieldFill.INSERT)
    private Long createUser;


    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long updateUser;


    //是否删除
    private Integer isDeleted;

    public DishVo changeToDishVo(Dish dish, HttpServletRequest request) {
        DishVo dishVo = new DishVo();
        dishVo.setId(this.id);
        dishVo.setName(this.name);
        dishVo.setCategoryId(this.categoryId);
        dishVo.setPrice(this.price);
        dishVo.setImage(this.image);
        dishVo.setDescription(this.description);
        dishVo.setUpdateTime(this.updateTime);
        return dishVo;
    }






}
